﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentValidation;

namespace Microhard.Permission.Validator
{
    public class OperationValidator : AbstractValidator<Microhard.Permission.Models.Operation>
    {
        public OperationValidator()
        {
            RuleSet("Insert", () =>
            {
                RuleFor(u => u.Name).NotEmpty().WithMessage("请填写名称").When(u => u.OperationID == Guid.Empty);
                RuleFor(u => u.KeyName).Length(1, 20).WithMessage("KeyName最大长度为20").When(u => u.OperationID == Guid.Empty);

            });
        }
    }
}
